<template>
	<view>
		<zmm-watermark :watermark="userStore.watermark" v-if="userStore.watermark"></zmm-watermark>
		<view class="content detail">
			<!--商品券-->
			<view class="detail-item">
				<uni-section title="商品券" type="line"></uni-section>
				<view class="detail-content">
					<!-- <view class="detail-text">ID：<text>{{info.id}}</text></view> -->
					<view class="detail-text">券名称：<text>{{info.name}}</text></view>
					<view class="detail-text">
						区域：
						<uni-tag size="small" :text="arrText(setStore.allProvinceList, info.regionCode)" />
					</view>
					<view class="detail-text">商品名称：<text>{{info.productName}}</text></view>
					<view class="detail-text">商品单位：<text>{{info.productUnit}}</text></view>
					<view class="detail-text">商品最少数量：<text>{{info.leastNumber}}</text></view>
					<view class="detail-text">优惠金额：<text>{{info.discountPrice}}</text></view>
					<view class="detail-text">券总量：<text>{{info.totalNumber}}</text></view>
					<view class="detail-text">每人最多可领：<text>{{info.mostUseNumber}}</text></view>
					<view class="detail-text">已领取：<text>{{info.receiveNumber}}</text></view>
					<view class="detail-text">已过期：<text>{{info.overdueNumber}}</text></view>
					<!-- <view class="detail-text main-flex">主体色：<view class="bg" :style="{backgroundColor: info.backColor}"></view></view> -->
					<view class="detail-text">开始时间：<text>{{info.startTime}}</text></view>
					<view class="detail-text">结束时间：<text>{{info.endTime}}</text></view>
					<view class="detail-text">广告语：<text>{{info.ad}}</text></view>
					<view class="main-flex detail-text detail-flex-start">
						广告图：
						<view class="detail-text_r">
							<up-image width="120rpx" height="120rpx" @click.stop="previewImg(info.backImg)" :src="info.backImg" :lazy-load="true"></up-image>
						</view>
					</view>
					<view class="detail-text">叠加使用：<uni-tag size="small" :type="info.accumulationFlag === 1 ? 'success' : ''" :text="info.accumulationFlag === 1 ? '可叠加' : '不可叠加'" /></view>
					<view class="detail-text" v-if="info.accumulationFlag === 1">每人最多可领：<text>{{info.mostUseNumber}}</text></view>
					<view class="detail-text">积分商城：<uni-tag size="small" :type="info.saleFlag === 1 ? 'success' : ''" :text="info.saleFlag === 1 ? '可兑换' : '不可兑换'" /></view>
					<view class="detail-text" v-if="info.saleFlag === 1">积分兑换：<text>{{info.integralValue}}</text></view>
					<view class="detail-text">
						状态：
						<uni-tag size="small" :type="info.status === 1 ? 'error' : 'success'" :text="arrText(couponStatusList, info.status)" />
					</view>
					<view class="detail-text">备注：<text>{{info.remark}}</text></view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { computed, onMounted, ref } from 'vue';
import { tab, auth, modal } from "@/plugins"
import { getTitle } from "@/utils/getter"
import { checkPermi, checkRole, checkOnlyPermi, checkOnlyRole } from "@/utils/permission"
import { couponProductDetail } from "@/api/erp_api/coupon"
import { copyText, arrText, previewImg } from '@/utils/ty.js';
import useUserStore from '@/store/modules/user'
import useSetStore from '@/store/modules/set';
import { couponStatusList } from '@/utils/config.js'

	const userStore = useUserStore()
	const setStore = useSetStore()
	onLoad((option) => {
		if (option.id) {
			id.value = option.id
			getDetail()
		}
	})
	
	// 数据查询
	const id = ref('')
	const info = ref({})
	const isLoading = ref(false)
	
	const getDetail = () => {
		const params = {
			id: id.value
		}
		isLoading.value = true
		uni.showLoading({
			title: '数据加载中...'
		})
		couponProductDetail(params).then(res => {
			info.value = res.data || {}
			isLoading.value = false
			uni.hideLoading()
    }).catch(() => {
			isLoading.value = false
			uni.hideLoading()
		})
	}
	
</script>

<style scoped lang="scss">
	.bg {
		width: 50px;
		height: 20px;
	}
</style>
